package com.hopechart.micro.config;

import org.springframework.data.transaction.ChainedTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.TransactionManagementConfigurer;

import javax.annotation.Resource;

/**
 * <p>
 *     <br/>数据源事务配置部分
 * </p>
 * @author daijiang@hopechart.com
 * @date 2017-10-30 08:59:38
 * @copyright 杭州鸿泉数字设备有限公司
 * @version V1.0.0
 */
//@Configuration
//@EnableTransactionManagement
//@ConditionalOnBean({ MasterDataSourceConfig.class})
public class DataSourcesAutoConfig implements TransactionManagementConfigurer {

	@Resource
	private MasterDataSourceConfig masterDataSourceConfig;

	@Override
	public PlatformTransactionManager annotationDrivenTransactionManager() {
		return new ChainedTransactionManager(
				masterDataSourceConfig.transactionManager()
		);
	}
}
